package com.smartens.boit.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.smartens.boit.R;
import com.smartens.boit.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 离线设备列表
 * @Author songtt
 * @Date 2021/3/4
 */

public class UnderlineActivity extends BaseActivity {
    private LinearLayout back;
    private RecyclerView recyclerView;
Adapter adapter;
List datalist;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_underline);
        back = findViewById(R.id.back);
        recyclerView=findViewById(R.id.myrecycler);
        datalist=new ArrayList();
        datalist.add(new Data("demo_01","16000301277"));
        adapter=new Adapter(datalist);
        adapter.notifyDataSetChanged();
        recyclerView.setAdapter(adapter);
        recyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));

        adapter.notifyDataSetChanged();
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UnderlineActivity.this.finish();
            }
        });
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }
    class  Adapter extends RecyclerView.Adapter
    {
   List<Data> list;
   public  Adapter (List list)
   {
       this.list=list;
   }
        @NonNull
        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view= LayoutInflater.from(UnderlineActivity.this).inflate(R.layout.item_abnormal, parent, false);
            MyHolder myHolder=new MyHolder(view);
            return myHolder;
        }

        @Override
        public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        MyHolder myHolder= (MyHolder) holder;
        myHolder.title.setText(list.get(position).title);
            myHolder.bianhao.setText(list.get(position).bianhao);
        }

        @Override
        public int getItemCount() {
            return list.size();
        }
        class  MyHolder extends RecyclerView.ViewHolder
        {
            TextView title;
            TextView bianhao;
            public  MyHolder(View view)
            {
                super(view);
                title = view.findViewById(R.id.name);
                bianhao = view.findViewById(R.id.number);
            }
        }
    }
    class Data
    {
        String title;
        String bianhao;
        public  Data(String title,String bianhao)
        {
            this.title=title;
            this.bianhao=bianhao;
        }
    }
}